@extends('layout.master')

@section('title')
   Your Cart 
@stop

@section('header')
    @parent
@stop

@section('username')
	{{ Auth::user()->userName }}
@stop

@section('side-menu')
    @parent
@stop

@section('content')
    <h3 style="border-bottom: 1px dotted"> <img alt="album.Title" src="/img/cart.png" /> Cart </h3> <br />
    
    @if(!empty($status))
    <div class='alert alert-info'>
    	{{ $status }}
    </div>
    @endif

    @if(empty($cart))
        <h3> Your cart is currently empty. Please add some products. </h3>
    @else
    <table class="table table-stripped">
        <thead>
            <th> Name </th>
            <th> Price </th>
            <th> Quantity </th>
            <th> </th>
            <th> Total </th>
        </thead>
        <tbody>
            <?php $total = 0; 
            foreach($cart as $item)
            {
                $total += $item['quantity'] * $item['price'];
				
                echo "
                <tr>
                    <td>  " .$item['name'].  "</td>
                    <td>  " .$item['price']. "</td>
                    <td>  " .$item['quantity']. " </td>
                    <td> <a href='/product/increment/".$item['id']."'> <i class='icon-plus'></i> </a> <a href='/product/decrement/".$item['id']."' style='padding-left: 20px;'> <i class='icon-minus'></i> </a>	</td>
                    <td>  " .$item['quantity'] * $item['price']. " </td>
                    <td> <a href='/product/remove/".$item['id']."'>Remove Item</a>	</td>                    
                </tr>";

            }
            
            ?>

            <tr> 
                <td> </td> <td></td> <td> </td> <td> <h6>Sub Total = R {{$total}} </h6> </td>
        </tbody>
    </table>

    <form action="/users/checkout" method="get">
        <button type="submit" name="submit" class="btn btn-success span3"> Proceed To Checkout </button>
    </form>

    <form action="/cart/destroy" method="post">
        <button type="submit" name="submit" class="btn btn-danger span3"> Clear Cart </button>
    </form>
    @endif
@stop

@section('scripts')

@stop


